using System.Data;
using Maps.Models;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;

namespace Maps {
    public class Migrations : DataMigrationImpl {

        public int Create() 
        {
			// Creating table MapRecord
			SchemaBuilder.CreateTable("MapRecord", table => table
				.ContentPartRecord()
				.Column("Place", DbType.String)
			);
            ContentDefinitionManager.AlterPartDefinition(typeof(MapPart).Name, 
                cfg => cfg.Attachable());
            return 1;
        }

        public int UpdateFrom1() 
        {
            ContentDefinitionManager.AlterTypeDefinition("MapWidget", 
                cfg => cfg
                .WithPart("MapPart")
                .WithPart("WidgetPart")
                .WithPart("CommonPart")
                .WithSetting("Stereotype", "Widget"));
            return 2;
        }
    }
}